export default class MyEvent {
    constructor() {
        this.eventObj = {};
    }
    addEvent(eventName, fn) {

        if (typeof this.eventObj[eventName] === "undefined") {
            this.eventObj[eventName] = [];
        }

        this.eventObj[eventName].push(fn);
    }
    trigger(eventName) {
         if (typeof this.eventObj[eventName] !== "undefined") {
            this.eventObj[eventName].forEach(fn => {
                fn();
            })
        } else {
            throw Error("参数传递错误");
        }
    }
}